package day4;

import java.lang.ref.SoftReference;

//测试Object类
public class TestObject {
    public static void main(String[] args) {
      /*TestObject t = new TestObject();
        System.out.println(t);
        */
        //1.对象类
        TestObject t1 = new TestObject();
        TestObject t2 = t1;
        TestObject t3 = new TestObject();
        System.out.println("t1:" + t1.hashCode());
        System.out.println("t2:" + t2.hashCode());
        System.out.println("t3:" + t3.hashCode());

        //2.基本类型封装类 Integer Long Byte
        Integer num1 = 1000;
        Integer num2 = new Integer(1000);
        Long num3 = 1000L;
        System.out.println("num1:" + num1.hashCode());
        System.out.println("num2:" + num2.hashCode());
        System.out.println("num3:" + num3.hashCode());

        //3.String类，可能会出现bug，哈希冲突
        //哈希冲突:值是不同的，但是hashCode反而相同
        String s1 = "java";
        String s2 = new String("java");
        System.out.println("s1:" + s1.hashCode());
        System.out.println("s2:" + s2.hashCode());
        //哈希冲突:值是不同的，但是hashCode反而相同
        String s3 = "重地";
        String s4 = "通话";
        System.out.println("s3:" +s3.hashCode());
        System.out.println("s4:" +s4.hashCode());
    }
}
